# -*- coding:utf-8 -*-
# created by jinss

f = open("stock_data", mode="r+", encoding="utf-8")

# 1、加载到内存中
data = f.read()
new_data = data.replace("路飞学城", "吉贝尔")
# 2、清空文件
f.seek(0)
# 截断文件
f.truncate()
# 把新内容写到硬盘
f.write(new_data)
f.close()